package com.lgz.dbcourse.mapper;

import com.lgz.dbcourse.dto.MovieDTO;
import com.lgz.dbcourse.entity.MovieEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Author: LGZ
 * @Date: 2021/4/10 19:24
 * @Description:
 */
public interface MovieMapper {

    /**
     * TODO
     * @Description 创建影片
     * @Author lgz
     * @Date 2021/4/10 16:46
     * @param movieEntity : 影片实体
     */
    void insertMovie(@Param("movieEntity") MovieEntity movieEntity);

    /**
     * TODO
     * @Description 修改影片信息
     * @Author lgz
     * @Date 2021/4/10 18:54
     * @param movieEntity : 影片实体
     */
    void updateMovie(@Param("movieEntity")MovieEntity movieEntity);

    /**
     * TODO
     * @Description 删除影片
     * @Author lgz
     * @Date 2021/4/10 19:18
     * @param movieEntity : 影片实体
     */
    @Delete("DELETE FROM movie WHERE movie_id = #{movieEntity.movieId}")
    void deleteMovie(@Param("movieEntity")MovieEntity movieEntity);

    /**
     * TODO
     * @Description 获取所有影片信息
     * @Author lgz
     * @Date 2021/4/11 10:35
     * @return : com.lgz.dbcourse.dto.MovieDTO[]
     */
    @Select("SELECT * FROM movie")
    MovieDTO[] getAllMovie();

    /**
     * TODO
     * @Description 按ID查找影片
     * @Author lgz
     * @Date 2021/4/11 10:43
     * @param movieEntity : 影片实体
     * @return : com.lgz.dbcourse.dto.MovieDTO
     */
    @Select("SELECT * FROM movie WHERE movie_id = #{movieEntity.movieId}")
    MovieDTO getMovieById(@Param("movieEntity")MovieEntity movieEntity);

}
